﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	SecurityConcept.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

namespace Smart.Common.Security
{
	/// <summary>
	/// Security concept define main conception of securing securable objects
	/// </summary>
	public abstract class SecurityConcept
	{
		/// <summary>
		/// Security context
		/// </summary>
		public SecurityContext Ctx { get; set; }

		/// <summary>
		/// Ensure runtime support is loaded (executed once application starts)
		/// </summary>
		public abstract void LoadRuntimeSupport();

		/// <summary>
		/// Return security principal by <paramref name="sourcePrincipal"/>
		/// </summary>
		public abstract string GetSecurityPrincipal(string sourcePrincipal);

		/// <summary>
		/// Create assignments
		/// </summary>
		/// <returns></returns>
		protected virtual SecuritySecurableAssignments CreateAssignments(SecurableType securableType, ISecurable securable, SecurityPolicy policy, bool inherit, bool currentScopeOnly)
		{
			return new SecuritySecurableAssignments(securableType, securable, policy, inherit, currentScopeOnly);
		}

		/// <summary>
		/// Returns security assignments
		/// </summary>
		public abstract SecuritySecurableAssignments GetSecurityAssignments(SecurableType securableType, ISecurable securable, SecurityPolicy policy);

		/// <summary>
		/// Security concept define main conception of securing securable objects
		/// </summary>
		protected SecurityConcept(SecurityContext ctx)
		{
			Ctx = ctx;
		}
	}
}